/*
 *  levelUpGame - PngSequencePlayer.h
 *  Copyright 2011 W. Reckman. All rights reserved.
 */
#ifndef PNG_SEQUENCE_PLAYER
#define PNG_SEQUENCE_PLAYER

#include <string>
#include <vector>
#include "ofxDirList.h"
#include "ofTypes.h"

using std::string;

class PngSequencePlayer {
public:
	enum PNG_SEQ_PLAY_MODE {
		PSP_FORWARD,
		PSP_BACKWARD,
		PSP_LOOP_FORWARD,
		PSP_LOOP_BACKWARD,
		PSP_LOOP_PINGPONG
	};
	
	static const int MAX_IMAGE_FILES;
	static const int DEFAULT_FRAMERATE;
	
	PngSequencePlayer();
	~PngSequencePlayer();
	
	bool loadSequence( const string& path_, const string& prefix_ );
	void clear();
	
	void play();
	void stop();
	void rewind();
	
	void update();
	void draw( int x, int y ) const;
	void draw( int x, int y, int w, int h ) const;
	
	void setFrameRate( int frameRate_ );
	void setMode( PNG_SEQ_PLAY_MODE mode_ );
	
	const ofPoint& getSize() const;
	bool isPlaying() const;
	int getFrameRate() const;
	int getNumFrames() const;
	int getCurrentFrame() const;
	PNG_SEQ_PLAY_MODE getMode() const;
	
private:
	typedef std::vector<ofImage*> vec_ofImageP;
	
	ofxDirList dirList;
	
	ofPoint size;
	int frameRate;
	float frameDuration;
	PNG_SEQ_PLAY_MODE mode;
	
	vec_ofImageP seqImages;
	
	bool playing;
	bool pingpongForward;
	int currentFrame;
	float lastElapsedTime;
};

#endif /* ! PNG_SEQUENCE_PLAYER */
